﻿using T0yK4T.IO;

namespace ToyChat.Server
{
    /// <summary>
    /// An interface used by a userhandler to manage user logins / registrations
    /// </summary>
    public interface ILoginModule
    {
        /// <summary>
        /// Attempts to authenticate the user information given in the specified <see cref="LoginChallenge"/>
        /// </summary>
        /// <param name="connection">The connection that needs to be authenticated</param>
        /// <param name="requireLogin">Specifies whether or not logging in is actually required for a connection to succeed</param>
        /// <param name="dbHandler">The database handler to use for looking up user informations</param>
        /// <param name="info">Will contain a <see cref="IUserInfo"/> object that represents the user</param>
        /// <returns>True if succesful, otherwsie false</returns>
        bool Authenticate(CryptoConnection connection, bool requireLogin, IDatabaseHandler dbHandler, out IUserInfo info);

        ///// <summary>
        ///// Attempts to register a new user in the database using informations from the specified <see cref="UserRegistrationPacket"/>
        ///// </summary>
        ///// <param name="pkt">The <see cref="UserRegistrationPacket"/> that contains informations about the new user</param>
        ///// <param name="newInfo">If succesful, this will be set to a new instance of <see cref="UserInfo"/> taken from the database</param>
        ///// <param name="dbHandler">The <see cref="IDatabaseHandler"/> to use for creating the user</param>
        ///// <returns>True if succesful, otherwise false</returns>
        //bool Register(UserRegistrationPacket pkt, IDatabaseHandler dbHandler, out IUserInfo newInfo);
    }
}